#include "Handle.h"

using namespace Shared;

#ifdef __linux__

bool Shared::LibHandle::Avail()
{
    return handle;
}

bool Shared::LibHandle::Open(const char *path)
{
    handle = dlopen(path, RTLD_LAZY);
    return handle;
}

int Shared::LibHandle::Close()
{
    return dlclose(handle);
}
void *Shared::LibHandle::GetProcAddr(const char *funcName)
{
    return dlsym(handle, funcName);
};
#endif // __li

#ifdef _WIN32
// HMODULE handle = LoadLibrary("../testShared/build/Debug/test.dll");

bool Shared::LibHandle::Avail()
{
    return handle;
}

bool Shared::LibHandle::Open(const char *path)
{
    handle = LoadLibrary(path);
    return handle;
}

void *Shared::LibHandle::GetProjAddr(const char *funcName)
{
    return GetProcAddress((HMODULE)handle, funcName);
}

int Shared::LibHandle::Close()
{
    return FreeLibrary((HMODULE)handle);
};
#endif // _WIN33
